// pages/video-detail/video-detail.js
import {reqgetDetailVideoData, reqgetDetailMvUrl, reqgetRelatedAllVideo} from "../../service/homeVideo"
Page({
  data: {
    id: 0,
    mvUrl: '',
    mvInfo: {},
    relatedVideo: [],
    danmuList:
    [{
      text: '第 1s 出现的弹幕hhhhhhh',
      color: '#ff0000',
      time: 1
    }, {
      text: '第 3s 出现的弹幕dddddd',
      color: '#ff00ff',
      time: 3
    },{
      text: '第 6s 出现的弹幕6666666',
      color: '#ff00ff',
      time: 6
    }],
  },
  onLoad(options){
    this.setData({id: options.id})
    this.getDetailVideoData()
    this.getDetailMvUrl()
    this.getRelatedAllVideo()
  },

  // 获取mvurl
  async getDetailMvUrl() {
    const res = await reqgetDetailMvUrl(this.data.id)
    this.setData({mvUrl: res.data.url})
  },

  // 获取详情页信息
  async getDetailVideoData() {
    const res = await reqgetDetailVideoData(this.data.id)
    this.setData({mvInfo: res.data});
  },

  // 获取相关视频
  async getRelatedAllVideo() {
    const res = await reqgetRelatedAllVideo(this.data.id)
    this.setData({relatedVideo: res.data})
  }

})